import React, { Component, useEffect, useState } from 'react';
import ResumeList from './components/resumeList';
import SearchDom from '@src/components/Search';
import EditModal from './components/editModal';
import { Button } from 'antd'
import './resume.styl'

function Resume() {
  const [dataSource, setDataSource] = useState([])
  const [open, setOpen] = useState(false)
  const [confirmLoading, setConfirmLoading] = useState(false)
  const [rowData, setRowData] = useState({})
  const editSubmit = (data) => {
    console.log(data)
  }
  const searchList = [
    {
      label: '手机号',
      key: 'phone',
      type: 'input'
    },
    {
      label: '学校名称',
      key: 'schoolName',
      type: 'input'
    },
    {
      label: '专业',
      key: 'majorName',
      type: 'input'
    }
  ]
  const submitSearch = (searchData) => {
    console.log(searchData)
  }
  const handleBtnsClick = (type) => {
    if (type === 1) {
      // 新增
      setRowData({})
      setOpen(true)
    }
    if (type === 2) {
      // 批量删除
    }
  }
  useEffect(() => {
    setDataSource([{
      id: '123',
      phone: '18519232239',
      createTime: '2022-10-21',
      userName: '王小杰'
    },{
      id: '124',
      phone: '18519232234',
      createTime: '2022-10-21'
    }])
  }, [])
  return (
    <>
      <SearchDom searchList={searchList} submitSearch={submitSearch}/>
      <div className='btns-wrapper'>
        <Button type="primary" onClick={() => handleBtnsClick(1)}>
          新增
        </Button>
        <Button type="primary" onClick={() => handleBtnsClick(2)} danger>
          批量删除
        </Button>
      </div>
      <ResumeList dataSource={dataSource} setOpen={setOpen} setRowData={setRowData}/>
      <EditModal
        open={open}
        setOpen={setOpen}
        confirmLoading={confirmLoading}
        setConfirmLoading={setConfirmLoading}
        editSubmit={editSubmit}
        initialValues={rowData}
      />
    </>
  )
}

export default Resume;